package com.allwees.bs.module.fms.req.query;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.allwees.bs.core.modelbase.branch.EBranchType;
import com.allwees.bs.core.modelbase.req.QueryReq;
import com.allwees.bs.module.fms.entity.MerchantWithdrawAccount;
import com.allwees.core.common.constant.EWithdrawAccountType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.StringUtils;

/**
 * 商户提现账户QueryReq
 *
 * @author yangylsky
 * @since 2020-01-03
 *
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
public class MerchantWithdrawAccountQueryReq extends QueryReq<MerchantWithdrawAccount> {
	private EBranchType branchType;

	private EWithdrawAccountType type;

	private String branchUuid;

	@Override
	protected void buildQuery(QueryWrapper<MerchantWithdrawAccount> queryWrapper) {
		queryWrapper.eq(StringUtils.isNotBlank(branchUuid), "branch_uuid", branchUuid);
		queryWrapper.and(StringUtils.isNotBlank(q), wrapper -> {
				wrapper.eq("uuid", q)
					.or().eq("account_no", q)
					.or().eq("name", q)
					.or().eq("id_no", q);
			});
		queryWrapper.eq(null != branchType, "branch_type", branchType);
		queryWrapper.eq(null != type, "type", type);
	}
}
